//
//  WHLoginViewController.m
//  WHWlProxyDemo
//
//  Created by shengmeng chen on 2021/7/28.
//

#import "WHLoginViewController.h"
#import "WHLoginView.h"
#import "WHLoginModel.h"
#import "WHTabBarController.h"

@interface WHLoginViewController ()

@property (nonatomic,strong)WHLoginView *wHLoginView;

@end

@implementation WHLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:self.wHLoginView];
    __weak __typeof(self) weakSelf = self;
    self.wHLoginView.clickBtnBlock = ^(NSString * _Nonnull phone, NSString * _Nonnull qcode, NSString * _Nonnull name) {
        WHLoginModel*model = [WHLoginModel new];
        model.phone    = phone;
        model.qcode    = qcode;
        model.username = name;
        
        BOOL isSucces = [WHLoginModel saveLoginModel:model];
        if (isSucces) {
            NSLog(@"用户信息保存成功");
            kApp.userPhone =model.phone;
            kApp.userQcode =model.qcode;
            kApp.userName  =model.username;
            WHTabBarController  *bsTabVC = [[WHTabBarController alloc]init];
            bsTabVC.modalPresentationStyle = UIModalPresentationFullScreen;
           [weakSelf presentModalViewController:bsTabVC animated:YES];
        }
        
    };
}

-(WHLoginView *)wHLoginView
{
    if (!_wHLoginView) {
        _wHLoginView = [[WHLoginView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH)];
    }
    return _wHLoginView;
}

@end
